<template>
  <div class="app-container">
    <!-- 工具栏 -->
    <!-- <tl-list-toolbar ref="toolbar" :isDisplayAdd="false" :isDisplayDeleteBatch="editable"
      @add="openAddDialog('editForm')" @exportExcel="doExportExcel" :isDisplayExport="false"
      @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize"
      @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0">
      <template slot="left-btn">
        <el-button class="filter-item" type="primary" icon="el-icon-plus"
          @click="openAddDialog('tlEditSaveAndCopyForm')">新增任命</el-button>
        <el-button class="filter-item" type="primary" icon="el-icon-plus" @click="openAddDialog('tlEditRevokeForm')">
          新增撤销</el-button>
        <el-button class="filter-item" type="primary" icon="el-icon-download" @click="doExportExcel"
          v-hasPermission="['sys:excel:export']">导出</el-button>
      </template>
    </tl-list-toolbar> -->
    <div style="margin-top:6px">
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a
            >项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <!-- <el-table-column type="selection" width="55px" fixed="left" :selectable="doDisableCheckBox"></el-table-column> -->
        <el-table-column type="index" label="序号" width="55px" align="center"></el-table-column>
        <el-table-column prop="dispappointmenttype" label="任命类型" width="100px" sortable="custom" sort-by="appointmenttype" align="center" header-align="center" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="usercode" label="工号" width="100px" sortable="custom" sort-by="usercode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="username" label="姓名" width="100px" sortable="custom" sort-by="username" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="workgroup" label="工作组名称" width="150px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispprojectrole" label="项目角色" width="150px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="duty" label="职责" min-width="280px" sortable="custom" sort-by="duty" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="appointdate" label="任命日期" width="100px" sortable="custom" sort-by="appointdate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="revokedate" label="撤销日期" width="100px" sortable="custom" sort-by="revokedate" align="center" header-align="center" :formatter="dateFormat" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="dispstate" label="状态" width="100px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-edit ref="editForm" @refresh="doRefresh" :parentId="parentId"></tl-edit>
      <!-- <tl-edit-for-series-add ref="editForSeriesAddForm" @refresh="doRefresh" :parentId="parentId"></tl-edit-for-series-add> -->
      <tl-edit-save-and-copy ref="tlEditSaveAndCopyForm" @refresh="doRefresh" :parentId="parentId" :projectCode="projectCode"></tl-edit-save-and-copy>
      <tl-edit-revoke ref="tlEditRevokeForm" @refresh="doRefresh" :parentId="parentId" :projectCode="projectCode"> </tl-edit-revoke>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
import tlEditSaveAndCopy from './editSaveAndCopy'
import tlEditRevoke from './editRevoke'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
import { checkPermission } from '@tapui/utils/permission'
import { filterObjectNull, rmbFormat } from '@tapui/utils/util'
export default {
  name: 'sdProjectTeam',
  mixins: [mixin_list],
  components: { tlEdit, tlEditSaveAndCopy, tlEditRevoke },
  data() {
    return {
      description: '项目任命-项目组成员-列表查询',
      urlPrefix: '/sd/projectTeam/',
      url: {
        queryCodeList: '/sd/projectTeam/dataCodeList'
      },
      reduceHeight: 282,
      // 排序参数
      sorterInfo: {
        sidx: 'appointmenttype',
        sord: 'asc'
      },
      isQueryOnCreated: true
    }
  },
  props: {
    parentId: {
      type: [Number, String],
      default: ''
    },
    projectCode: {
      type: [String],
      default: ''
    },
    projectinfo: {}
  },
  methods: {
    /** 获取查询参数 */
    getQueryParams() {
      let param = {}
      if (this.superQueryParams) {
        param['superQueryParams'] = encodeURI(this.superQueryParams)
      }
      Object.assign(param, this.queryParam, this.sorterInfo, this.filtersInfo)
      param.currentPage = this.pageInfo.currentPage
      param.pageSize = this.pageInfo.pageSize
      param.qry_teamIndex = 1
      param.qry_enabled = 1
      param.qry_state = 9
      param.qry_appointmenttype = 1
      param.qry_projectcode = this.projectinfo.projectcode
      return filterObjectNull(param)
    },
    /** 表格双击事件 */
    doRowDbClick(row, column, event) {
      if (row.appointmenttype === '2') {
        this.openViewDialog('tlEditRevokeForm', row[this.$refs.mainTable.rowKey])
      } else {
        this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
      }
    },
    // 禁用表格前面的选择
    doDisableCheckBox(row, index) {
      if (row.state !== 0 && row.state !== 2) {
        return false
      } else {
        return true
      }
    },
    initPage() {
      if (this.editable) {
        this.rowDbClickActionType = 'edit'
      } else {
        this.rowDbClickActionType = 'view'
      }
    },
    // 非母子表，无需传
    beforeLoadData() {
      //   if (!this.parentId) {
      //     return false
      //   }
      this.queryParam.parentid = this.parentId
      return true
    }
  }
}
</script>

<style scoped>
.app-container {
  margin: 0;
}
</style>
